<head>
    <meta charset="UTF-8">
<title>算法训练 Minimum Cost Flow</title>
<link rel="stylesheet" href="../css/main.css">
</head>
 <p>【问题描述】</p>
<p class="MsoNormal" align="left"><span style="font-size:
12.0pt;font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">&nbsp; &nbsp;你已经被雇佣来 使用现有的旧管道组件以建设一个在旧厂房两点间运水的系统。旧管道系统由管道和管道接口器组成。原有管道在接口器处相交。有的旧管道已经被移除，只在接口器上留下了洞&mdash;&mdash;他们本来是连在洞上的。如果水流入某个接口器，它将流出整个洞并逐渐充满整个大楼&mdash;&mdash;这显然不能让人接受。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">你可以通过在一些开孔间加入新管道，或者塞子关闭其他开孔来挽回这种状况。当你用一条新的管道连接两个洞时（必须位于两个不同的节点上），这两个洞不再开放并且水可以流经个新的管道。加入一条新的管道的花费等同于两个节点中心的距离。购买塞子塞住一个洞的花费是</span><span lang="EN-US" style="font-size:12.0pt">0.5</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">。你不需要考虑那些永远不会有水到达的节点上的洞。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">有两个结点是特殊的。一个叫做源，是水流入新系统的点。另一个叫做汇，是水需要到达的地方。在所有新的塞子和管道被加入系统后，水将被以一个足够达到指定高度的压力注入源点（当然是在没有渗漏的情况下）。你可以选择任意的压力。而且可以放心，在系统工作时压力不会改变。当然，压力应该足够达到源点和汇点。你的任务是找到让水从源流到汇的最小费用，同时保证水不会渗入大楼。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">下面的图中。黑点代表开着的洞，节点</span><span lang="EN-US" style="font-size:12.0pt">1</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">是源点，节点</span><span lang="EN-US" style="font-size:12.0pt">7</span><span style="font-size:12.0pt;font-family:
宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin">是汇点。黑点在圆上的位置没有意义，仅作说明用途）。</span><span lang="EN-US" style="font-size:12.0pt;mso-no-proof:yes"><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">  <v:stroke joinstyle="miter">  <v:formulas>   <v:f eqn="if lineDrawn pixelLineWidth 0">   <v:f eqn="sum @0 1 0">   <v:f eqn="sum 0 0 @1">   <v:f eqn="prod @2 1 2">   <v:f eqn="prod @3 21600 pixelWidth">   <v:f eqn="prod @3 21600 pixelHeight">   <v:f eqn="sum @0 0 1">   <v:f eqn="prod @6 1 2">   <v:f eqn="prod @7 21600 pixelWidth">   <v:f eqn="sum @8 21600 0">   <v:f eqn="prod @7 21600 pixelHeight">   <v:f eqn="sum @10 21600 0">  </v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>  <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect">  <o:lock v:ext="edit" aspectratio="t"> </o:lock></v:path></v:stroke></v:shapetype><v:shape id="图片_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width:242.25pt;height:159pt;visibility:visible;mso-wrap-style:square">  <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" o:title=""> </v:imagedata></v:shape></span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span lang="EN-US" style="font-size:12.0pt">&nbsp;<img src="http://lx.lanqiao.cn/RequireFile.do?fid=BH3A7g4r" width="330" height="209" alt="" /></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">水依照物理原理流过这个系统。如果压力足够让一个节点灌满水，那这些节点将始终充满了水。如果管道横向延伸或者从一个节点向下延伸，那么水也会从那些管道流过。水也会沿着管道向上，直到达到压力高度的限制。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">当然，如果水达到了一个接口器上的洞，它将会流出并充满整个大楼。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">在第一个样例中，你可以连接接口</span><span lang="EN-US" style="font-size:12.0pt">1</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">和</span><span lang="EN-US" style="font-size:12.0pt">5<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">当然，如果水流到一个节点中的开孔，那它将会流出洞并且充满整个大楼。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:
minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin">在第一个样例中，你可以花费代价</span><span lang="EN-US" style="font-size:12.0pt">3</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">连接节点</span><span lang="EN-US" style="font-size:12.0pt">1,5</span><span style="font-size:12.0pt;font-family:
宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin">，塞上</span><span lang="EN-US" style="font-size:
12.0pt">2</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:
minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin">的开孔。并且让水压恰好到达接口</span><span lang="EN-US" style="font-size:12.0pt">7</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">。水将充满接口器</span><span lang="EN-US" style="font-size:12.0pt">1</span><span style="font-size:12.0pt;font-family:
宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin">、</span><span lang="EN-US" style="font-size:
12.0pt">2</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:
minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin">、</span><span lang="EN-US" style="font-size:12.0pt">5</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">、</span><span lang="EN-US" style="font-size:12.0pt">6</span><span style="font-size:12.0pt;font-family:
宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin">和</span><span lang="EN-US" style="font-size:
12.0pt">7</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:
minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin">，不会流得更高了。一个不同的方案（花费更多）是塞住所有的开孔（花费</span><span lang="EN-US" style="font-size:12.0pt">5</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">），并且让水流经所有的洞。通过连接</span><span lang="EN-US" style="font-size:12.0pt">1</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">、</span><span lang="EN-US" style="font-size:12.0pt">6</span><span style="font-size:12.0pt;font-family:
宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin">并塞住</span><span lang="EN-US" style="font-size:
12.0pt">2</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:
minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin">、</span><span lang="EN-US" style="font-size:12.0pt">5</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">的开孔不能解决问题，因此接口器</span><span lang="EN-US" style="font-size:12.0pt">6</span><span style="font-size:12.0pt;
font-family:宋体;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:
Calibri;mso-hansi-theme-font:minor-latin">不可以连接管道。</span><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">注：假设现有的管道和任何新的管道出了那些他们被连接的节点外，彼此不相交也没有其他接口。就是说，即使一条从</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">A</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">到</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">B</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">的直线经过了</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">C</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">，任何</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">A</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">到</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">B</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">的管道也不会碰到</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">C</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">。</span></p>
<p>【输入格式】</p>
<p><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">每个测试点的第一行包含两个正整数</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">N</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">和</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">M</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">。</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">N (2 </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> N </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> 400)</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">表示大楼中接口的数量，</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">M(0 </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> M </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> 50 000)</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">表示现有可用管道的数量。接下来的</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">N</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">行每行包含四个正整数</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">xi,yi,zi</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">和</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">ki </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">（</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">&minus;10 000 </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> xi, yi, zi </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> 10 000</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">，</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">0 </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> ki </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> 400</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">，</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> i = 1, 2, ...,N</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">）。第</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">i</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">行描述了结点</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">i</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">：</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">(xi, yi, zi)</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">是地</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">i</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">个结点在三维坐标系中的位置。</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">Ki</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">表示交界处洞的个数。接下来</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">M</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">行的每一行包含两个整数</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">aj</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">和</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">bj</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">（</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">1 </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> aj &lt; bj </span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">&le;</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;"> N</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">）。表示第</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">j</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">条原有管道连接了</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">aj</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">和</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">bj</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">两个节点。每对点之间最多有一条管道。并且没有两个节点位于同一个坐标。源是节点</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">1</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">，汇是节点</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">N</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">。</span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span lang="EN-US" style="font-size:
12.0pt"><o:p></o:p></span></p>
<p>&nbsp;【输出格式】</p>
<p>&nbsp;</p>
<p><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">对于每个测试点，打出测试点编号。之后，若它存在一些新的管道和塞子可以用来建设所需的系统，打印出连接源节点带汇节点的最小代价（精确到小数点后四位）。如果不可能连接源汇，则打印出单词</span><span lang="EN-US" style="text-indent: 21pt; font-size: 12pt;">impossible</span><span style="text-indent: 21pt; font-size: 12pt; font-family: 宋体;">。</span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span lang="EN-US" style="font-size:12.0pt"><o:p></o:p></span></p>
<p>&nbsp;【样例输入】<b><span lang="EN-US" style="font-size:12.0pt">&nbsp;</span></b></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">7 6<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">2 0 1 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">0 0 0 2<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">1 0 4 3<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">3 0 4 3<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">5 0 1 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">3 0 2 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">5 0 3 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">1 2<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">1 3<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">3 4<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">4 7<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">5 7<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">6 7<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">4 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">2 0 0 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">3 0 1 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">4 1 0 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">5 1 1 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">1 2<o:p></o:p></span></p>
<p>【样例输出】<b><span lang="EN-US" style="font-size:12.0pt">&nbsp;</span></b></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">&nbsp;</span><span lang="EN-US" style="font-size:12.0pt">Case 1: 4.0000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt">Case 2: impossible</span></p>